package com.scedu.handler;

import com.scedu.config.ProjectUrlConfig;
import com.scedu.exception.SellAuthorizeException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class SellExceptionHandler {
    @Autowired
    private ProjectUrlConfig projectUrlConfig;
    //拦截登录异常
    @ExceptionHandler(value = SellAuthorizeException.class)
    public ModelAndView handlerAuthorizeException(){
     return new ModelAndView("redirect:"
       .concat(projectUrlConfig.getWechatOpenAuthorize())
       .concat("/sell/wechat/qrauthorize")
       .concat("?returnUrl=")
       .concat(projectUrlConfig.getSell())
       .concat("/sell/seller/login")
     );
    }
}
